#ifndef __D3DX10MATH_SWIG_H
#define __D3DX10MATH_SWIG_H
#include "msTypes.i"

#define D3DX_PI    ((FLOAT)  3.141592654f)
#define D3DX_1BYPI ((FLOAT)  0.318309886f)

#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f))
#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI))

#define D3DX_16F_DIG          3                // # of decimal digits of precision
#define D3DX_16F_EPSILON      4.8875809e-4f    // smallest such that 1.0 + epsilon != 1.0
#define D3DX_16F_MANT_DIG     11               // # of bits in mantissa
#define D3DX_16F_MAX          6.550400e+004    // max value
#define D3DX_16F_MAX_10_EXP   4                // max decimal exponent
#define D3DX_16F_MAX_EXP      15               // max binary exponent
#define D3DX_16F_MIN          6.1035156e-5f    // min positive value
#define D3DX_16F_MIN_10_EXP   (-4)             // min decimal exponent
#define D3DX_16F_MIN_EXP      (-14)            // min binary exponent
#define D3DX_16F_RADIX        2                // exponent radix
#define D3DX_16F_ROUNDS       1                // addition rounding: near

typedef struct D3DXFLOAT16
{
public:
    D3DXFLOAT16() {};
    D3DXFLOAT16( FLOAT );
    D3DXFLOAT16( const D3DXFLOAT16& );

    BOOL operator == ( const D3DXFLOAT16& ) const;
    BOOL operator != ( const D3DXFLOAT16& ) const;
} D3DXFLOAT16, *LPD3DXFLOAT16;


typedef struct D3DXVECTOR2
{

public:
    D3DXVECTOR2() {};
    D3DXVECTOR2( const FLOAT * );
    D3DXVECTOR2( const D3DXFLOAT16 * );
    D3DXVECTOR2( FLOAT x, FLOAT y );

    // assignment operators
    D3DXVECTOR2& operator += ( const D3DXVECTOR2& );
    D3DXVECTOR2& operator -= ( const D3DXVECTOR2& );
    D3DXVECTOR2& operator *= ( FLOAT );
    D3DXVECTOR2& operator /= ( FLOAT );

    // unary operators
    D3DXVECTOR2 operator + () const;
    D3DXVECTOR2 operator - () const;

    // binary operators
    D3DXVECTOR2 operator + ( const D3DXVECTOR2& ) const;
    D3DXVECTOR2 operator - ( const D3DXVECTOR2& ) const;
    D3DXVECTOR2 operator * ( FLOAT ) const;
    D3DXVECTOR2 operator / ( FLOAT ) const;

    BOOL operator == ( const D3DXVECTOR2& ) const;
    BOOL operator != ( const D3DXVECTOR2& ) const;


public:
    FLOAT x, y;
} D3DXVECTOR2, *LPD3DXVECTOR2;



//--------------------------
// 2D Vector (16 bit)
//--------------------------

typedef struct D3DXVECTOR2_16F
{
public:
    D3DXVECTOR2_16F() {};
    D3DXVECTOR2_16F( const FLOAT * );
    D3DXVECTOR2_16F( const D3DXFLOAT16 * );
    D3DXVECTOR2_16F( const D3DXFLOAT16 &x, const D3DXFLOAT16 &y );

    BOOL operator == ( const D3DXVECTOR2_16F& ) const;
    BOOL operator != ( const D3DXVECTOR2_16F& ) const;

public:
    D3DXFLOAT16 x, y;

} D3DXVECTOR2_16F, *LPD3DXVECTOR2_16F;

typedef struct _D3DVECTOR {
    float x;
    float y;
    float z;
} D3DVECTOR;

typedef struct D3DXVECTOR3 : public D3DVECTOR
{
public:
    D3DXVECTOR3() {};
    D3DXVECTOR3( const FLOAT * );
    D3DXVECTOR3( const D3DVECTOR& );
    D3DXVECTOR3( const D3DXFLOAT16 * );
    D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z );



    // assignment operators
    D3DXVECTOR3& operator += ( const D3DXVECTOR3& );
    D3DXVECTOR3& operator -= ( const D3DXVECTOR3& );
    D3DXVECTOR3& operator *= ( FLOAT );
    D3DXVECTOR3& operator /= ( FLOAT );

    // unary operators
    D3DXVECTOR3 operator + () const;
    D3DXVECTOR3 operator - () const;

    // binary operators
    D3DXVECTOR3 operator + ( const D3DXVECTOR3& ) const;
    D3DXVECTOR3 operator - ( const D3DXVECTOR3& ) const;
    D3DXVECTOR3 operator * ( FLOAT ) const;
    D3DXVECTOR3 operator / ( FLOAT ) const;

   

    BOOL operator == ( const D3DXVECTOR3& ) const;
    BOOL operator != ( const D3DXVECTOR3& ) const;

} D3DXVECTOR3, *LPD3DXVECTOR3;


typedef struct D3DXVECTOR3_16F
{
public:
    D3DXVECTOR3_16F() {};
    D3DXVECTOR3_16F( const FLOAT * );
    D3DXVECTOR3_16F( const D3DVECTOR& );
    D3DXVECTOR3_16F( const D3DXFLOAT16 * );
    D3DXVECTOR3_16F( const D3DXFLOAT16 &x, const D3DXFLOAT16 &y, const D3DXFLOAT16 &z );

    // casting
    
   

    // binary operators
    BOOL operator == ( const D3DXVECTOR3_16F& ) const;
    BOOL operator != ( const D3DXVECTOR3_16F& ) const;

public:
    D3DXFLOAT16 x, y, z;

} D3DXVECTOR3_16F, *LPD3DXVECTOR3_16F;


typedef struct D3DXVECTOR4
{
public:
    D3DXVECTOR4() {};
    D3DXVECTOR4( const FLOAT* );
    D3DXVECTOR4( const D3DXFLOAT16* );
    D3DXVECTOR4( const D3DVECTOR& xyz, FLOAT w );
    D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w );

    // casting
   
    

    // assignment operators
    D3DXVECTOR4& operator += ( const D3DXVECTOR4& );
    D3DXVECTOR4& operator -= ( const D3DXVECTOR4& );
    D3DXVECTOR4& operator *= ( FLOAT );
    D3DXVECTOR4& operator /= ( FLOAT );

    // unary operators
    D3DXVECTOR4 operator + () const;
    D3DXVECTOR4 operator - () const;

    // binary operators
    D3DXVECTOR4 operator + ( const D3DXVECTOR4& ) const;
    D3DXVECTOR4 operator - ( const D3DXVECTOR4& ) const;
    D3DXVECTOR4 operator * ( FLOAT ) const;
    D3DXVECTOR4 operator / ( FLOAT ) const;

   

    BOOL operator == ( const D3DXVECTOR4& ) const;
    BOOL operator != ( const D3DXVECTOR4& ) const;

public:
    FLOAT x, y, z, w;
} D3DXVECTOR4, *LPD3DXVECTOR4;


//--------------------------
// 4D Vector (16 bit)
//--------------------------
typedef struct D3DXVECTOR4_16F
{
public:
    D3DXVECTOR4_16F() {};
    D3DXVECTOR4_16F( const FLOAT * );
    D3DXVECTOR4_16F( const D3DXFLOAT16* );
    D3DXVECTOR4_16F( const D3DXVECTOR3_16F& xyz, const D3DXFLOAT16& w );
    D3DXVECTOR4_16F( const D3DXFLOAT16& x, const D3DXFLOAT16& y, const D3DXFLOAT16& z, const D3DXFLOAT16& w );

    // casting
  
   

    // binary operators
    BOOL operator == ( const D3DXVECTOR4_16F& ) const;
    BOOL operator != ( const D3DXVECTOR4_16F& ) const;

public:
    D3DXFLOAT16 x, y, z, w;

} D3DXVECTOR4_16F, *LPD3DXVECTOR4_16F;


typedef struct _D3DMATRIX {
    float m[4][4];
} D3DMATRIX;

typedef struct D3DXMATRIX : public D3DMATRIX
{
public:
    D3DXMATRIX() {};
    D3DXMATRIX( const FLOAT * );
    D3DXMATRIX( const D3DMATRIX& );
    D3DXMATRIX( const D3DXFLOAT16 * );
    D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
                FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
                FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
                FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );

    // casting operators
    
  

    // assignment operators
    D3DXMATRIX& operator *= ( const D3DXMATRIX& );
    D3DXMATRIX& operator += ( const D3DXMATRIX& );
    D3DXMATRIX& operator -= ( const D3DXMATRIX& );
    D3DXMATRIX& operator *= ( FLOAT );
    D3DXMATRIX& operator /= ( FLOAT );

    // unary operators
    D3DXMATRIX operator + () const;
    D3DXMATRIX operator - () const;

    // binary operators
    D3DXMATRIX operator * ( const D3DXMATRIX& ) const;
    D3DXMATRIX operator + ( const D3DXMATRIX& ) const;
    D3DXMATRIX operator - ( const D3DXMATRIX& ) const;
    D3DXMATRIX operator * ( FLOAT ) const;
    D3DXMATRIX operator / ( FLOAT ) const;

   

    BOOL operator == ( const D3DXMATRIX& ) const;
    BOOL operator != ( const D3DXMATRIX& ) const;

} D3DXMATRIX, *LPD3DXMATRIX;



typedef struct _D3DXMATRIXA16 : public D3DXMATRIX
{
    _D3DXMATRIXA16() {}
    _D3DXMATRIXA16( const FLOAT * );
    _D3DXMATRIXA16( const D3DMATRIX& );
    _D3DXMATRIXA16( const D3DXFLOAT16 * );
    _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14,
                    FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24,
                    FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34,
                    FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 );

    

} _D3DXMATRIXA16;


typedef struct D3DXQUATERNION
{

public:
    D3DXQUATERNION() {}
    D3DXQUATERNION( const FLOAT * );
    D3DXQUATERNION( const D3DXFLOAT16 * );
    D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w );

   
   
    

    // assignment operators
    D3DXQUATERNION& operator += ( const D3DXQUATERNION& );
    D3DXQUATERNION& operator -= ( const D3DXQUATERNION& );
    D3DXQUATERNION& operator *= ( const D3DXQUATERNION& );
    D3DXQUATERNION& operator *= ( FLOAT );
    D3DXQUATERNION& operator /= ( FLOAT );

    // unary operators
    D3DXQUATERNION  operator + () const;
    D3DXQUATERNION  operator - () const;

    // binary operators
    D3DXQUATERNION operator + ( const D3DXQUATERNION& ) const;
    D3DXQUATERNION operator - ( const D3DXQUATERNION& ) const;
    D3DXQUATERNION operator * ( const D3DXQUATERNION& ) const;
    D3DXQUATERNION operator * ( FLOAT ) const;
    D3DXQUATERNION operator / ( FLOAT ) const;

    

    BOOL operator == ( const D3DXQUATERNION& ) const;
    BOOL operator != ( const D3DXQUATERNION& ) const;

    FLOAT x, y, z, w;
} D3DXQUATERNION, *LPD3DXQUATERNION;


typedef struct D3DXPLANE
{
public:
    D3DXPLANE() {}
    D3DXPLANE( const FLOAT* );
    D3DXPLANE( const D3DXFLOAT16* );
    D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d );

    // casting
    
   

    // assignment operators
    D3DXPLANE& operator *= ( FLOAT );
    D3DXPLANE& operator /= ( FLOAT );

    // unary operators
    D3DXPLANE operator + () const;
    D3DXPLANE operator - () const;

    // binary operators
    D3DXPLANE operator * ( FLOAT ) const;
    D3DXPLANE operator / ( FLOAT ) const;

    

    BOOL operator == ( const D3DXPLANE& ) const;
    BOOL operator != ( const D3DXPLANE& ) const;

    FLOAT a, b, c, d;
} D3DXPLANE, *LPD3DXPLANE;


typedef struct D3DXCOLOR
{
public:
    D3DXCOLOR() {}
    D3DXCOLOR( DWORD argb );
    D3DXCOLOR( const FLOAT * );
    D3DXCOLOR( const D3DXFLOAT16 * );
    D3DXCOLOR( const D3DCOLORVALUE& );
    D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a );


    // assignment operators
    D3DXCOLOR& operator += ( const D3DXCOLOR& );
    D3DXCOLOR& operator -= ( const D3DXCOLOR& );
    D3DXCOLOR& operator *= ( FLOAT );
    D3DXCOLOR& operator /= ( FLOAT );

    // unary operators
    D3DXCOLOR operator + () const;
    D3DXCOLOR operator - () const;

    // binary operators
    D3DXCOLOR operator + ( const D3DXCOLOR& ) const;
    D3DXCOLOR operator - ( const D3DXCOLOR& ) const;
    D3DXCOLOR operator * ( FLOAT ) const;
    D3DXCOLOR operator / ( FLOAT ) const;


    BOOL operator == ( const D3DXCOLOR& ) const;
    BOOL operator != ( const D3DXCOLOR& ) const;

    FLOAT r, g, b, a;
} D3DXCOLOR, *LPD3DXCOLOR;


D3DXFLOAT16*  D3DXFloat32To16Array
    ( D3DXFLOAT16 *pOut, const FLOAT *pIn, UINT n );

FLOAT*  D3DXFloat16To32Array
    ( FLOAT *pOut, const D3DXFLOAT16 *pIn, UINT n );

FLOAT D3DXVec2Length( const D3DXVECTOR2 *pV );

FLOAT D3DXVec2LengthSq( const D3DXVECTOR2 *pV );

FLOAT D3DXVec2Dot( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );

FLOAT D3DXVec2CCW( const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );

D3DXVECTOR2* D3DXVec2Add( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );

D3DXVECTOR2* D3DXVec2Subtract( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );

D3DXVECTOR2* D3DXVec2Minimize( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );


D3DXVECTOR2* D3DXVec2Maximize
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2 );

D3DXVECTOR2* D3DXVec2Scale
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, FLOAT s );


D3DXVECTOR2* D3DXVec2Lerp
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2,
      FLOAT s );


D3DXVECTOR2* D3DXVec2Normalize( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV );


D3DXVECTOR2* D3DXVec2Hermite
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pT1,
      const D3DXVECTOR2 *pV2, const D3DXVECTOR2 *pT2, FLOAT s );

D3DXVECTOR2* D3DXVec2CatmullRom
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV0, const D3DXVECTOR2 *pV1,
      const D3DXVECTOR2 *pV2, const D3DXVECTOR2 *pV3, FLOAT s );


D3DXVECTOR2* D3DXVec2BaryCentric
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV1, const D3DXVECTOR2 *pV2,
      const D3DXVECTOR2 *pV3, FLOAT f, FLOAT g);


D3DXVECTOR4* D3DXVec2Transform
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );


D3DXVECTOR2* D3DXVec2TransformCoord
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );


D3DXVECTOR2* D3DXVec2TransformNormal
    ( D3DXVECTOR2 *pOut, const D3DXVECTOR2 *pV, const D3DXMATRIX *pM );
     

D3DXVECTOR4* D3DXVec2TransformArray
    ( D3DXVECTOR4 *pOut, UINT OutStride, const D3DXVECTOR2 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n);

D3DXVECTOR2* D3DXVec2TransformCoordArray
    ( D3DXVECTOR2 *pOut, UINT OutStride, const D3DXVECTOR2 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );


D3DXVECTOR2* D3DXVec2TransformNormalArray
    ( D3DXVECTOR2 *pOut, UINT OutStride, const D3DXVECTOR2 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );
    
    

FLOAT D3DXVec3Length
    ( const D3DXVECTOR3 *pV );

FLOAT D3DXVec3LengthSq
    ( const D3DXVECTOR3 *pV );

FLOAT D3DXVec3Dot
    ( const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Cross
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Add
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Subtract
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Minimize
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Maximize
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2 );

D3DXVECTOR3* D3DXVec3Scale
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, FLOAT s);

D3DXVECTOR3* D3DXVec3Lerp
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
      FLOAT s );


D3DXVECTOR3*  D3DXVec3Normalize
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV );

D3DXVECTOR3*  D3DXVec3Hermite
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pT1,
      const D3DXVECTOR3 *pV2, const D3DXVECTOR3 *pT2, FLOAT s );

D3DXVECTOR3*  D3DXVec3CatmullRom
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV0, const D3DXVECTOR3 *pV1,
      const D3DXVECTOR3 *pV2, const D3DXVECTOR3 *pV3, FLOAT s );

D3DXVECTOR3*  D3DXVec3BaryCentric
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
      const D3DXVECTOR3 *pV3, FLOAT f, FLOAT g);

D3DXVECTOR4*  D3DXVec3Transform
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );


D3DXVECTOR3*  D3DXVec3TransformCoord
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );

D3DXVECTOR3*  D3DXVec3TransformNormal
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXMATRIX *pM );
    
D3DXVECTOR4*  D3DXVec3TransformArray
    ( D3DXVECTOR4 *pOut, UINT OutStride, const D3DXVECTOR3 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );

D3DXVECTOR3*  D3DXVec3TransformCoordArray
    ( D3DXVECTOR3 *pOut, UINT OutStride, const D3DXVECTOR3 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );

D3DXVECTOR3*  D3DXVec3TransformNormalArray
    ( D3DXVECTOR3 *pOut, UINT OutStride, const D3DXVECTOR3 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );

D3DXVECTOR3*  D3DXVec3Project
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DVIEWPORT9 *pViewport,
      const D3DXMATRIX *pProjection, const D3DXMATRIX *pView, const D3DXMATRIX *pWorld);

D3DXVECTOR3*  D3DXVec3Unproject
    ( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DVIEWPORT9 *pViewport,
      const D3DXMATRIX *pProjection, const D3DXMATRIX *pView, const D3DXMATRIX *pWorld);
      
D3DXVECTOR3*  D3DXVec3ProjectArray
    ( D3DXVECTOR3 *pOut, UINT OutStride,const D3DXVECTOR3 *pV, UINT VStride,const D3DVIEWPORT9 *pViewport,
      const D3DXMATRIX *pProjection, const D3DXMATRIX *pView, const D3DXMATRIX *pWorld, UINT n);

D3DXVECTOR3*  D3DXVec3UnprojectArray
    ( D3DXVECTOR3 *pOut, UINT OutStride, const D3DXVECTOR3 *pV, UINT VStride, const D3DVIEWPORT9 *pViewport,
      const D3DXMATRIX *pProjection, const D3DXMATRIX *pView, const D3DXMATRIX *pWorld, UINT n);




FLOAT D3DXVec4Length
    ( const D3DXVECTOR4 *pV );

FLOAT D3DXVec4LengthSq
    ( const D3DXVECTOR4 *pV );

FLOAT D3DXVec4Dot
    ( const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2 );

D3DXVECTOR4* D3DXVec4Add
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);

D3DXVECTOR4* D3DXVec4Subtract
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);

D3DXVECTOR4* D3DXVec4Minimize
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);

D3DXVECTOR4* D3DXVec4Maximize
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2);

D3DXVECTOR4* D3DXVec4Scale
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, FLOAT s);

D3DXVECTOR4* D3DXVec4Lerp
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
      FLOAT s );



D3DXVECTOR4*  D3DXVec4Cross
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
      const D3DXVECTOR4 *pV3);

D3DXVECTOR4*  D3DXVec4Normalize
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV );

D3DXVECTOR4*  D3DXVec4Hermite
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pT1,
      const D3DXVECTOR4 *pV2, const D3DXVECTOR4 *pT2, FLOAT s );

D3DXVECTOR4*  D3DXVec4CatmullRom
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV0, const D3DXVECTOR4 *pV1,
      const D3DXVECTOR4 *pV2, const D3DXVECTOR4 *pV3, FLOAT s );

D3DXVECTOR4*  D3DXVec4BaryCentric
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV1, const D3DXVECTOR4 *pV2,
      const D3DXVECTOR4 *pV3, FLOAT f, FLOAT g);

D3DXVECTOR4*  D3DXVec4Transform
    ( D3DXVECTOR4 *pOut, const D3DXVECTOR4 *pV, const D3DXMATRIX *pM );
    
D3DXVECTOR4*  D3DXVec4TransformArray
    ( D3DXVECTOR4 *pOut, UINT OutStride, const D3DXVECTOR4 *pV, UINT VStride, const D3DXMATRIX *pM, UINT n );


D3DXMATRIX* D3DXMatrixIdentity
    ( D3DXMATRIX *pOut );

BOOL D3DXMatrixIsIdentity
    ( const D3DXMATRIX *pM );

FLOAT  D3DXMatrixDeterminant
    ( const D3DXMATRIX *pM );

HRESULT  D3DXMatrixDecompose
    ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, 
	  D3DXVECTOR3 *pOutTranslation, const D3DXMATRIX *pM );

D3DXMATRIX*  D3DXMatrixTranspose
    ( D3DXMATRIX *pOut, const D3DXMATRIX *pM );


D3DXMATRIX*  D3DXMatrixMultiply
    ( D3DXMATRIX *pOut, const D3DXMATRIX *pM1, const D3DXMATRIX *pM2 );

D3DXMATRIX*  D3DXMatrixMultiplyTranspose
    ( D3DXMATRIX *pOut, const D3DXMATRIX *pM1, const D3DXMATRIX *pM2 );

D3DXMATRIX*  D3DXMatrixInverse
    ( D3DXMATRIX *pOut, FLOAT *pDeterminant, const D3DXMATRIX *pM );

D3DXMATRIX*  D3DXMatrixScaling
    ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz );

D3DXMATRIX*  D3DXMatrixTranslation
    ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z );

D3DXMATRIX*  D3DXMatrixRotationX
    ( D3DXMATRIX *pOut, FLOAT Angle );

D3DXMATRIX*  D3DXMatrixRotationY
    ( D3DXMATRIX *pOut, FLOAT Angle );

D3DXMATRIX*  D3DXMatrixRotationZ
    ( D3DXMATRIX *pOut, FLOAT Angle );

D3DXMATRIX*  D3DXMatrixRotationAxis
    ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pV, FLOAT Angle );

D3DXMATRIX*  D3DXMatrixRotationQuaternion
    ( D3DXMATRIX *pOut, const D3DXQUATERNION *pQ);


D3DXMATRIX*  D3DXMatrixRotationYawPitchRoll
    ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );

D3DXMATRIX*  D3DXMatrixTransformation
    ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pScalingCenter,
      const D3DXQUATERNION *pScalingRotation, const D3DXVECTOR3 *pScaling,
      const D3DXVECTOR3 *pRotationCenter, const D3DXQUATERNION *pRotation,
      const D3DXVECTOR3 *pTranslation);


D3DXMATRIX*  D3DXMatrixTransformation2D
    ( D3DXMATRIX *pOut, const D3DXVECTOR2* pScalingCenter, 
      FLOAT ScalingRotation, const D3DXVECTOR2* pScaling, 
      const D3DXVECTOR2* pRotationCenter, FLOAT Rotation, 
      const D3DXVECTOR2* pTranslation);


D3DXMATRIX*  D3DXMatrixAffineTransformation
    ( D3DXMATRIX *pOut, FLOAT Scaling, const D3DXVECTOR3 *pRotationCenter,
      const D3DXQUATERNION *pRotation, const D3DXVECTOR3 *pTranslation);

D3DXMATRIX*  D3DXMatrixAffineTransformation2D
    ( D3DXMATRIX *pOut, FLOAT Scaling, const D3DXVECTOR2* pRotationCenter, 
      FLOAT Rotation, const D3DXVECTOR2* pTranslation);


D3DXMATRIX*  D3DXMatrixLookAtRH
    ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt,
      const D3DXVECTOR3 *pUp );

D3DXMATRIX*  D3DXMatrixLookAtLH
    ( D3DXMATRIX *pOut, const D3DXVECTOR3 *pEye, const D3DXVECTOR3 *pAt,
      const D3DXVECTOR3 *pUp );

D3DXMATRIX*  D3DXMatrixPerspectiveRH
    ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

D3DXMATRIX*  D3DXMatrixPerspectiveLH
    ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

D3DXMATRIX*  D3DXMatrixPerspectiveFovRH
    ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );

D3DXMATRIX*  D3DXMatrixPerspectiveFovLH
    ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf );

D3DXMATRIX*  D3DXMatrixPerspectiveOffCenterRH
    ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
      FLOAT zf );

D3DXMATRIX*  D3DXMatrixPerspectiveOffCenterLH
    ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
      FLOAT zf );

D3DXMATRIX*  D3DXMatrixOrthoRH
    ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );


D3DXMATRIX*  D3DXMatrixOrthoLH
    ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf );

D3DXMATRIX*  D3DXMatrixOrthoOffCenterRH
    ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
      FLOAT zf );


D3DXMATRIX*  D3DXMatrixOrthoOffCenterLH
    ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn,
      FLOAT zf );

D3DXMATRIX*  D3DXMatrixShadow
    ( D3DXMATRIX *pOut, const D3DXVECTOR4 *pLight,
      const D3DXPLANE *pPlane );

D3DXMATRIX*  D3DXMatrixReflect
    ( D3DXMATRIX *pOut, const D3DXPLANE *pPlane );



FLOAT D3DXQuaternionLength
    ( const D3DXQUATERNION *pQ );


FLOAT D3DXQuaternionLengthSq
    ( const D3DXQUATERNION *pQ );

FLOAT D3DXQuaternionDot
    ( const D3DXQUATERNION *pQ1, const D3DXQUATERNION *pQ2 );

D3DXQUATERNION* D3DXQuaternionIdentity
    ( D3DXQUATERNION *pOut );

BOOL D3DXQuaternionIsIdentity
    ( const D3DXQUATERNION *pQ );

D3DXQUATERNION* D3DXQuaternionConjugate
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );




void  D3DXQuaternionToAxisAngle
    ( const D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle );

D3DXQUATERNION*  D3DXQuaternionRotationMatrix
    ( D3DXQUATERNION *pOut, const D3DXMATRIX *pM);

D3DXQUATERNION*  D3DXQuaternionRotationAxis
    ( D3DXQUATERNION *pOut, const D3DXVECTOR3 *pV, FLOAT Angle );

D3DXQUATERNION*  D3DXQuaternionRotationYawPitchRoll
    ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll );


D3DXQUATERNION*  D3DXQuaternionMultiply
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
      const D3DXQUATERNION *pQ2 );

D3DXQUATERNION*  D3DXQuaternionNormalize
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );

D3DXQUATERNION*  D3DXQuaternionInverse
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );

D3DXQUATERNION*  D3DXQuaternionLn
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );

D3DXQUATERNION*  D3DXQuaternionExp
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ );
      

D3DXQUATERNION*  D3DXQuaternionSlerp
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
      const D3DXQUATERNION *pQ2, FLOAT t );

D3DXQUATERNION*  D3DXQuaternionSquad
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
      const D3DXQUATERNION *pA, const D3DXQUATERNION *pB,
      const D3DXQUATERNION *pC, FLOAT t );


void  D3DXQuaternionSquadSetup
    ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut,
      const D3DXQUATERNION *pQ0, const D3DXQUATERNION *pQ1, 
      const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3 );

D3DXQUATERNION*  D3DXQuaternionBaryCentric
    ( D3DXQUATERNION *pOut, const D3DXQUATERNION *pQ1,
      const D3DXQUATERNION *pQ2, const D3DXQUATERNION *pQ3,
      FLOAT f, FLOAT g );



FLOAT D3DXPlaneDot
    ( const D3DXPLANE *pP, const D3DXVECTOR4 *pV);


FLOAT D3DXPlaneDotCoord
    ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV);


FLOAT D3DXPlaneDotNormal
    ( const D3DXPLANE *pP, const D3DXVECTOR3 *pV);

D3DXPLANE* D3DXPlaneScale
    (D3DXPLANE *pOut, const D3DXPLANE *pP, FLOAT s);



D3DXPLANE*  D3DXPlaneNormalize
    ( D3DXPLANE *pOut, const D3DXPLANE *pP);

D3DXVECTOR3*  D3DXPlaneIntersectLine
    ( D3DXVECTOR3 *pOut, const D3DXPLANE *pP, const D3DXVECTOR3 *pV1,
      const D3DXVECTOR3 *pV2);

D3DXPLANE*  D3DXPlaneFromPointNormal
    ( D3DXPLANE *pOut, const D3DXVECTOR3 *pPoint, const D3DXVECTOR3 *pNormal);

D3DXPLANE*  D3DXPlaneFromPoints
    ( D3DXPLANE *pOut, const D3DXVECTOR3 *pV1, const D3DXVECTOR3 *pV2,
      const D3DXVECTOR3 *pV3);

D3DXPLANE*  D3DXPlaneTransform
    ( D3DXPLANE *pOut, const D3DXPLANE *pP, const D3DXMATRIX *pM );
    
D3DXPLANE*  D3DXPlaneTransformArray
    ( D3DXPLANE *pOut, UINT OutStride, const D3DXPLANE *pP, UINT PStride, const D3DXMATRIX *pM, UINT n );


D3DXCOLOR* D3DXColorNegative
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC);

D3DXCOLOR* D3DXColorAdd
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);

D3DXCOLOR* D3DXColorSubtract
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);

D3DXCOLOR* D3DXColorScale
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC, FLOAT s);

D3DXCOLOR* D3DXColorModulate
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2);

D3DXCOLOR* D3DXColorLerp
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC1, const D3DXCOLOR *pC2, FLOAT s);

D3DXCOLOR*  D3DXColorAdjustSaturation
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC, FLOAT s);

D3DXCOLOR*  D3DXColorAdjustContrast
    (D3DXCOLOR *pOut, const D3DXCOLOR *pC, FLOAT c);



FLOAT  D3DXFresnelTerm
    (FLOAT CosTheta, FLOAT RefractionIndex);     

class ID3DXMatrixStack : public IUnknown
{
public:
    virtual HRESULT Pop() = 0;
    virtual HRESULT Push() = 0;
    virtual HRESULT LoadIdentity() = 0;
    virtual HRESULT LoadMatrix( const D3DXMATRIX* pM ) = 0;
    virtual HRESULT MultMatrix(const D3DXMATRIX* pM ) = 0;
    virtual HRESULT MultMatrixLocal( const D3DXMATRIX* pM ) = 0;
    virtual HRESULT RotateAxis(const D3DXVECTOR3* pV, FLOAT Angle) = 0;
    virtual HRESULT RotateAxisLocal(const D3DXVECTOR3* pV, FLOAT Angle) = 0;
    virtual HRESULT RotateYawPitchRoll(FLOAT Yaw, FLOAT Pitch, FLOAT Roll) = 0;
    virtual HRESULT RotateYawPitchRollLocal( FLOAT Yaw, FLOAT Pitch, FLOAT Roll) = 0;
    virtual HRESULT Scale(FLOAT x, FLOAT y, FLOAT z) = 0;
    virtual HRESULT ScaleLocal(FLOAT x, FLOAT y, FLOAT z) = 0;
    virtual HRESULT Translate(FLOAT x, FLOAT y, FLOAT z ) = 0;
    virtual HRESULT TranslateLocal( FLOAT x, FLOAT y, FLOAT z) = 0;
    D3DXMATRIX* GetTop() = 0;
};

HRESULT D3DXCreateMatrixStack( 
        DWORD               Flags, 
        LPD3DXMATRIXSTACK*  ppStack);


FLOAT*  D3DXSHEvalDirection
    (  FLOAT *pOut, UINT Order, const D3DXVECTOR3 *pDir );


FLOAT*  D3DXSHRotate
    ( FLOAT *pOut, UINT Order, const D3DXMATRIX *pMatrix, const FLOAT *pIn );
 
FLOAT*  D3DXSHRotateZ
    ( FLOAT *pOut, UINT Order, FLOAT Angle, const FLOAT *pIn );
   
FLOAT*  D3DXSHAdd
    ( FLOAT *pOut, UINT Order, const FLOAT *pA, const FLOAT *pB );


FLOAT*  D3DXSHScale
    ( FLOAT *pOut, UINT Order, const FLOAT *pIn, const FLOAT Scale );

FLOAT  D3DXSHDot
    ( UINT Order, const FLOAT *pA, const FLOAT *pB );

FLOAT*  D3DXSHMultiply2( FLOAT *pOut, const FLOAT *pF, const FLOAT *pG);
FLOAT*  D3DXSHMultiply3( FLOAT *pOut, const FLOAT *pF, const FLOAT *pG);
FLOAT*  D3DXSHMultiply4( FLOAT *pOut, const FLOAT *pF, const FLOAT *pG);
FLOAT*  D3DXSHMultiply5( FLOAT *pOut, const FLOAT *pF, const FLOAT *pG);
FLOAT*  D3DXSHMultiply6( FLOAT *pOut, const FLOAT *pF, const FLOAT *pG);

HRESULT  D3DXSHEvalDirectionalLight
    ( UINT Order, const D3DXVECTOR3 *pDir, 
      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
      FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

HRESULT  D3DXSHEvalSphericalLight
    ( UINT Order, const D3DXVECTOR3 *pPos, FLOAT Radius,
      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
      FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

HRESULT  D3DXSHEvalConeLight
    ( UINT Order, const D3DXVECTOR3 *pDir, FLOAT Radius,
      FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity,
      FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );
      
HRESULT  D3DXSHEvalHemisphereLight
    ( UINT Order, const D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom,
      FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );

HRESULT  D3DXSHProjectCubeMap
    ( UINT uOrder, LPDIRECT3DCUBETEXTURE9 pCubeMap,
      FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut );


#endif